#pragma once

#include "List.h"
#include "ListItem.h"

enum ECategoryAction
{
  caNone      = 0,
  caBack      = 1,
  caOpen      = 2,
  caFavorites = 3
};

class CListItemCategory : public CListItem
{
public:
  TCHAR name[CATEGORY_TEXT_LENGTH];
  int   length;

  CListItemCategory() : length(0)
  { name[0] = 0; }

  void SetName(const TCHAR* szText)
  { ::StringCchCopy(name, CATEGORY_TEXT_LENGTH, szText); length = ::_tcslen(name); }

  // Drawing
  virtual void Draw(HDC hdc, const RECT& rc) const;

  virtual bool OnMouseClick(HWND hParent, int x, int y);
  virtual bool OnKeyUp(HWND hParent, int vKey);
  virtual bool OnLongTap(HWND hParent);

protected:
  virtual void PrepareDraw(HDC hdc, const RECT& rc) const;
};

class CListItemCategoryFav : public CListItemCategory
{
public:

protected:
  virtual void PrepareDraw(HDC hdc, const RECT& rc) const;
};

class CListItemCategoryBack : public CListItemCategory
{
public:
  virtual bool OnMouseClick(HWND hParent, int x, int y);
  virtual bool OnKeyUp(HWND hParent, int vKey);
  virtual bool OnLongTap(HWND hParent);

protected:
  virtual void PrepareDraw(HDC hdc, const RECT& rc) const;
};

class CListCategories : public CList
{
public:
  CListCategories(HWND hWnd);
  
  const TCHAR* GetCategoryName(int idx) const
  {
    if (idx < 0 || idx >= (int)items.size())
      return TEXT("");
    else
      return ((CListItemCategory*)items[idx])->name;
  }

  virtual void Draw(HDC hdc, HDC hdcTmp, const RECT& rClip);

protected:
  void Populate();
};
